package cn.iocoder.yudao.module.infra.dal.mysql.oss;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.module.infra.controller.admin.oss.vo.OssPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.oss.OssDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
 * oss Mapper
 *
 * @author guangpu
 */
@Mapper
public interface OssMapper extends BaseMapperX<OssDO> {

    default PageResult<OssDO> selectPage(OssPageReqVO reqVO) {
        return selectPage(reqVO, new QueryWrapperX<OssDO>()
                .likeIfPresent("id", reqVO.getId())
                .likeIfPresent("type", reqVO.getType())
                .orderByDesc("create_time"));
    }

    default List<OssDO> selectByIds(Collection<String> ids) {
        return selectList(new LambdaQueryWrapper<OssDO>().in(OssDO::getId, ids));
    }
}
